from selenium.webdriver.common.by import By

from common.base import Base
from common.functions import open_browser


class LoginPage(Base):
    login_url = 'http://139.129.26.163/user.php'

    def input_username(self, username):
        self.send_keys((By.NAME, 'username'), username)

    def input_password(self, password):
        self.send_keys((By.NAME, 'password'), password)

    def save(self):
        self.click((By.ID, 'remember'))

    def login(self):
        self.click((By.NAME, 'submit'))


if __name__ == '__main__':
    browser = open_browser()
    case = LoginPage(browser)
    case.get(case.login_url)
    case.input_username('yangyu')
    case.input_password('123456')
    case.save()
    case.login()
